<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
          <div class="table-operator">
            <rx-button alias="bpmOpinionLibAdd" :butn-icon="'plus'" :butn-type="'primary'" :show-no-right="true" @click="add">
                {{$ti18('rxList.newBtn','新建')}}
            </rx-button>
            <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0 && editEnable && selectedRowKeys.length > 0">
              <a-button style="margin-left: 8px">
                  {{ $ti18('rxList.moreBtn','更多')}}
               <a-icon type="down" /> </a-button>
              <a-menu slot="overlay">
                <a-menu-item
                  key="1"
                  @click="editOne"
                  v-if="editEnable && selectedRowKeys.length > 0"
                  alias="formRuleEdit"
                  :butn-type="'primary'"
                  :show-no-right="false"
                >
                  <a-icon type="edit" />{{$ti18('rxList.editBtn','编辑')}}
                </a-menu-item>
                <a-menu-item
                  key="2"
                  @click="delByIds(selectedRowKeys)"
                  v-if="removeEnable && selectedRowKeys.length > 0"
                  alias="formRuleDelete"
                  :butn-type="'danger'"
                  :show-no-right="false"
                >
                  <a-icon type="delete" />{{$ti18('rxList.delBtn','删除')}}
                </a-menu-item>
              </a-menu>
            </a-dropdown>
          </div>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-bpm/bpm/core/bpmOpinionLib/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                id-field="opId"
                @selectChange="onSelectChange"
        >
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="editEnable && showBtn(false)" @click="edit(record)">
                {{$ti18('rxList.editBtn', '编辑')}}
            </span>
            <span v-if="removeEnable && showBtn(false)" @click="delByIds([record.opId])">
                {{$ti18('rxList.delBtn','删除')}}
            </span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import BpmOpinionLibApi from '@/api/bpm/core/bpmOpinionLib'
  import BpmOpinionLibEdit from './BpmOpinionLibEdit'
  import {BaseList} from '@lowcode/jpaas-common-lib';
  export default {
    name: 'BpmOpinionLibList',
    mixins: [BaseList],

    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.userId','用户ID'), dataIndex: 'userId', width: 100},
          {title:  this.i18n('form.opinion','审批意见'), dataIndex: 'opText', width: 100},
          {title: this.$ti18("rxList.action","操作"), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:BpmOpinionLibEdit,
        comment:this.i18n('list.comment','意见收藏表'),
        widthHeight:['800px','600px']
      }
    },
    methods:{
        i18n(name, text, key) {
            return this.$ti18(name, text, "BpmOpinionLib", key);
        },
      delById(ids){
        return BpmOpinionLibApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return BpmOpinionLibApi.query(parameter)
      }
    }
  }
</script>
<style scoped>

</style>

